import React from "react";
import Menu from 'antd/lib/menu';

import routeWithUserSession from "@/components/ApplicationArea/routeWithUserSession";
import PageHeader from "@/components/PageHeader";
import OrgStructTree from "@/components/orgstruct/OrgStructTree";
import "./OrgStructList.less";
import routes from "@/services/routes";
class OrgStructList extends React.Component {
  state = {
    loading: true,
    orgstruct_enum: 'admin',
    items: [],
  };

  componentWillMount() {
    // Enums.items('orgstruct_enum').then(data => {
    //   data && this.setState({
    //     items: data,
    //     loading: false,
    //     orgstruct_enum: data[0].value,
    //   });
    // });
  };

  tabsClick = e => {
    this.setState({
      orgstruct_enum: e.key,
    });
  };

  renderTabs() {
    return (
      <Menu onClick={this.tabsClick} selectedKeys={[this.state.orgstruct_enum]} mode="horizontal">
      {this.state.items.map(item => (
        <Menu.Item key = {item.value}>
          {item.label}
        </Menu.Item>
      ))}
      </Menu>
    );
 };

  render() {
   // if (this.state.loading || this.state.items.length === 0) return null;

    return (
      <div className="settings-screen">
        <div className="container">
          <PageHeader title="部门" />
          {/* <div className="bg-white tiled"> */}
            {/* {this.renderTabs()} */}
            <div className="p-15">
              <OrgStructTree orgstruct_enum={this.state.orgstruct_enum}/>
            </div>
          </div>
        {/* </div> */}
      </div>
    );
  }
}

routes.register(
  "Orgstruct.List",
  routeWithUserSession({
    path: "/orgstruct",
    title: "部门",
    render: pageProps => <OrgStructList {...pageProps}/>,
  })
);
// export default [
//   routeWithUserSession({
//     path: "/orgstruct",
//     title: "部门",
//     render: pageProps => <OrgStructList {...pageProps} />,
//   }),
// ];
